import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import './widget/dialog.dart';

void main() {
  return runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Scaffold(
        appBar: AppBar(title: const Text('这是标题')), body: const HomePage()),
  ));
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    void onPressed() {
      Fluttertoast.showToast(
          msg: "This is Center Short Toast",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.CENTER,
          timeInSecForIosWeb: 1,
          backgroundColor: Colors.red,
          textColor: Colors.white,
          fontSize: 16.0);
    }

    void onPressed1() {
      showDialog(
          context: context,
          barrierDismissible: false,
          builder: (context) {
            return MyDialog(title: '这是标题', onPress: null);
          });
    }

    return Column(
      children: [
        ElevatedButton(onPressed: onPressed, child: const Text('点击')),
        const SizedBox(
          height: 20,
        ),
        ElevatedButton(
          onPressed: onPressed1,
          child: const Text('基本用法'),
        ),
      ],
    );
  }
}
